from Api.ihrm_loginApi import IhrmLogin

from common.assretTools import common_tools


class TestIhrmLogin(object):
    def setup_class(self):
        # 创建实例
        self.ihrm = IhrmLogin()

    def test_001_login_success(self):
        data = {"mobile": "13800000002", "password": "123456"}
        resp = self.ihrm.login(data)
        print("登录成功", resp.json())
        common_tools(resp,200,True,10000,  "成功")


    def test_002_pwd_error(self):
        data = {"mobile": "13800000002", "password": "123123"}
        resp = self.ihrm.login(data)
        print("密码错误", resp.json())
        common_tools(resp, 200, False, 20001, "用户名或密码错误")


    def test_003_mobile_not_registered(self):
        data = {"mobile": "13800001122", "password": "123456"}
        resp = self.ihrm.login(data)
        print("手机号未注册", resp.json())
        common_tools(resp, 200, False, 20001, "用户名或密码错误")

    def test_004_ten_mobile(self):
        data = {"mobile": "1380000000", "password": "123456"}
        resp = self.ihrm.login(data)
        print("10位手机号", resp.json())
        common_tools(resp, 200, False, 20001, "用户名或密码错误")

    def test_005_twelve_mobile(self):
        data = {"mobile": "138000000022", "password": "123456"}
        resp = self.ihrm.login(data)
        print("12位手机号", resp.json())
        common_tools(resp, 200, False, 20001, "用户名或密码错误")

    def test_006_null_mobile(self):
        data = {"mobile": None, "password": "123456"}
        resp = self.ihrm.login(data)
        print("手机号为空", resp.json())
        common_tools(resp, 200, False, 20001, "用户名或密码错误")

    def test_007_special_character_mobile(self):
        data = {"mobile": "13800000002a", "password": "123456"}
        resp = self.ihrm.login(data)
        print("手机号有特殊字符", resp.json())
        common_tools(resp, 200, False, 20001, "用户名或密码错误")

    def test_008_one_pwd(self):
        data = {"mobile": "13800000002", "password": 1}
        resp = self.ihrm.login(data)
        print("1位密码", resp.json())
        common_tools(resp, 200, False, 20001, "用户名或密码错误")

    def test_009_hundred_pwd(self):
        data = {"mobile": "13800000002", "password": "012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789"}
        resp = self.ihrm.login(data)
        print("100位密码", resp.json())
        common_tools(resp, 200, False, 20001, "用户名或密码错误")

    def test_010_null_pwd(self):
        data = {"mobile": "13800000002", "password": None}
        resp = self.ihrm.login(data)
        print("密码为空", resp.json())
        common_tools(resp, 200, False, 20001, "用户名或密码错误")

    def test_011_special_character_pwd(self):
        data = {"mobile": "13800000002", "password": "12345a"}
        resp = self.ihrm.login(data)
        print("密码有特殊字符", resp.json())
        common_tools(resp, 200, False, 20001, "用户名或密码错误")

    def test_012_more_parameter(self):
        data = {"mobile": "13800000002", "password": "123456","abc":"123"}
        resp = self.ihrm.login(data)
        print("多参", resp.json())
        common_tools(resp,200,True,10000,  "操作成功！")

    def test_013_lack_parameter(self):
        data = {"mobile": "13800000002"}
        resp = self.ihrm.login(data)
        print("少参", resp.json())
        common_tools(resp, 200, False, 20001, "用户名或密码错误")

    def test_014_null_parameter(self):
        data = None
        resp = self.ihrm.login(data)
        print("无参", resp.json())
        common_tools(resp, 200, False, 99999, "系统繁忙")

    def test_015_error_parameter(self):
        data = {"mobi": "13800000002", "pass": "123456"}
        resp = self.ihrm.login(data)
        print("错参", resp.json())
        common_tools(resp, 200, False, 20001, "用户名或密码错误")




